<!--{template common/header_common}-->
<link rel="stylesheet" type="text/css" href="{STATICURL}/register_simple/style/network.css?ver={FORMHASH}" />
<script type="text/javascript" >
	var seccodecheck 	= parseInt('$seccodecheck');
	var secqaacheck 	= parseInt('$secqaacheck');
	var waiting = '<img src="{IMGDIR}/loading.gif" />';
	var successed = '<img src="{IMGDIR}/succeed.png" />';
	var username_input = '{$this->setting['reginput']['username']}';
	var email_input = '{$this->setting['reginput']['email']}';
	var pass1_input = '{$this->setting['reginput']['password']}';
	var pass2_input = '{$this->setting['reginput']['password2']}';
	var realname_input = 'realname';
	var gender_input = 'gender';
	
	//begin action code
	window.onload = function(){
		var chk_realname 	= $(realname_input);
		chk_realname.onblur = function(){
			checkrealname(realname_input);
		}
		var chk_username 	= $(username_input);
		chk_username.onblur = function(){
			checkusername(username_input);
		}
		var chk_email		= $(email_input);
		chk_email.onblur 	= function(){
			checkemail(email_input);
		}
		var chk_pass1		= $(pass1_input);
		var chk_pass2		= $(pass2_input);
		chk_pass1.onblur = function(){
			var pass1_status = $('chk_' + pass1_input);
			if(this.value.length < 5){
				pass1_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_pass1" style="cursor:pointer" />';
				showPrompt('img_pass1', 'mouseover', 'Mật khẩu nhập vào không ít hơn 5 ký tự', 1000);
				return false;
			}else{
				pass1_status.innerHTML = successed;
			}
			if(chk_pass2.value.length != '' && this.value.length >= 5){
				checkpassword(pass1_input, pass2_input);
			}
		}
		chk_pass2.onblur = function(){
			checkpassword(pass1_input, pass2_input);
		}
		var chk_gender = $('gender');
		chk_gender.onblur = function(){
			checkgender('gender');	
		}
	}
	
	// Begin function code
	function checkrealname(id){
		var realname_status = $('chk_' + id);
		var realname = trim($(id).value);
		realname_status.innerHTML = waiting;
		if(realname.length > 5){
			realname_status.innerHTML = successed;	
			realname_status.className = 'successed';
		}else{
			realname_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_realname" style="cursor:pointer" />';
			showPrompt('img_realname', 'mouseover', 'Vui lòng nhập đầy đủ Họ và Tên của bạn!', 1000);
			return false;
		}
	}
	
	function checkusername(id, chm){
		var username_status = $('chk_'+id);
		username_status.innerHTML = waiting;
		username = trim($(id).value);
		var x = new Ajax();
		x.get('forum.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkusername&username=' + (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(username) : username), function(s) {
			if(s == 'succeed'){
				username_status.innerHTML = successed;
				username_status.className = 'successed';
			}else{
				username_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_username" style="cursor:pointer" >';
				username_status.className = 'erro';
				showPrompt('img_username', 'mouseover', s, 1000);
				return false;
			}
			
		});	
	}
	
	function checkemail(id){
		var email = trim($(id).value);
		var email_status = $('chk_' + id);
		email_status.innerHTML = waiting;
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)){
			email_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_email" style="cursor:pointer" />';
			email_status.className = 'erro';
			showPrompt('img_email', 'mouseover', 'Địa chỉ email bạn nhập vào không đúng!', 1000);
			return false;
		}
		var x = new Ajax();
		x.get('forum.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkemail&email=' + email, function(s){
			if(s == 'succeed'){
				email_status.innerHTML = successed;
				email_status.className = 'successed';
			}else{
				email_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_email" style="cursor:pointer" />';
				showPrompt('img_email', 'mouseover', s, 1000);
				email_status.className = 'erro';
				return false;
			}
		});
	}
	
	function checkpassword(id1, id2) {
		if(!$(id1).value && !$(id2).value){
			return;
		}
		var pass1_status = $('chk_' + id1);
		var pass2_status = $('chk_' + id2);
		if($(id1).value != $(id2).value){
			pass2_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_pass2" style="cursor:pointer" >';
			showPrompt('img_pass2', 'mouseover', 'Hai mật khẩu bạn nhập không khớp nhau. Hãy nhập đúng như mật khẩu bạn đã nhập ở trên!', 1000);
			return false;
		}else{
			pass2_status.innerHTML  = successed;
			pass1_status.className = 'successed';
			pass2_status.className = 'successed';
		}
	}
	
	function checkgender(id){
		var gender_status = $('chk_' + id);
		var value = $(id).value;
		if(value != '1' && value != '2'){
			gender_status.innerHTML = '<img src="{IMGDIR}/erro.png" id="img_gender" style="cursor:pointer" >';
			showPrompt('img_gender', 'mouseover', 'Xin vui lòng lựa chọn giới tính của bạn!', 1000);
			return false;
		}else{
			gender_status.innerHTML  = successed;
			gender_status.className = 'successed';
		}
	}
	
	function showbirthday(){
		var el = $('birthday');
		var birthday = el.value;
		el.length=0;
		el.options.add(new Option('Ngày', ''));
		for(var i=0;i<28;i++){
			el.options.add(new Option(i+1, i+1));
		}
		if($('birthmonth').value!="2"){
			el.options.add(new Option(29, 29));
			el.options.add(new Option(30, 30));
			switch($('birthmonth').value){
				case "1":
				case "3":
				case "5":
				case "7":
				case "8":
				case "10":
				case "12":{
					el.options.add(new Option(31, 31));
				}
			}
		} else if($('birthyear').value!="") {
			var nbirthyear=$('birthyear').value;
			if(nbirthyear%400==0 || (nbirthyear%4==0 && nbirthyear%100!=0)) el.options.add(new Option(29, 29));
		}
		el.value = birthday;
	}
	function upostsubmit(theform) {
		theform.regsubmitbtn.disabled = true
		theform.submit();
		return;
	}
	
	function checksecode(theform){
		if(in_array($('registerformsubmit').name, ['regsubmitbtn'])) {
			if(seccodecheck || secqaacheck) {
				var chk = 1, chkv = '';
				if(secqaacheck) {
					chkv = $('checksecqaaverify_' + theform.sechash.value).innerHTML;
					if(chkv.indexOf('loading') != -1) {
						setTimeout(function () { validate_form(theform); }, 100);
						chk = 0;
					} else if(chkv.indexOf('check_right') == -1) {
						showError('Câu hỏi xác nhận bị lỗi, vui lòng kiểm tra lại!');
						chk = 0;
					}
				}
				if(seccodecheck) {
					chkv = $('checkseccodeverify_' + theform.sechash.value).innerHTML;
					if(chkv.indexOf('loading') !== -1) {
						setTimeout(function () { validate_form(theform); }, 100);
						chk = 0;
					} else if(chkv.indexOf('check_right') === -1) {
						showError('Mã xác nhận không đúng, vui lòng kiểm tra lại!');
						chk = 0;
					}
				}
				if(chk) {
					upostsubmit(theform);
				}
			} else {
				upostsubmit(theform);
			}
			return false;
		}	
	}
	
	function checksubmit(theform){
		var username_status = $('chk_' + username_input);
		var email_status = $('chk_' + email_input);
		var pass1_status = $('chk_' + pass1_input);
		var pass2_status = $('chk_' + pass2_input);
		var realname_status = $('chk_' + realname_input);
		var gender_status = $('chk_' + gender_input);
		checkpassword(pass1_input, pass2_input);
		checkrealname(realname_input);
		checkgender('gender');
		
		if(username_status.className != 'successed'){
			showError('Tên tài khoản không hợp lệ, vui lòng kiểm tra lại!');
			return false;	
		}
		if(pass1_status.className != 'successed' || pass2_status.className != 'successed'){
			showError('Mật khẩu nhập vào không hợp lệ, vui lòng kiểm tra lại');
			return false;
		}
		if(email_status.className != 'successed'){
			showError('Địa chỉ email không hợp lệ, vui lòng kiểm tra lại!');
			return false;
		}
		
		if(realname_status.className != 'successed'){
			showError('Xin vui lòng nhập đầy đủ họ tên!');
			return false;
		}
		if(gender_status.className != 'successed'){
			showError('Xin vui lòng chọn giới tính của bạn');
			return false;
		}
		checksecode(theform);
	}
</script>
</head>
<body>
	<div id="append_parent"></div><div id="ajaxwaitid"></div>
    <div class="nfl" id="main_succeed" style="display: none">
		<div class="f_c altw">
			<div class="alert_right">
				<p id="succeedmessage"></p>
				<p id="succeedlocation" class="alert_btnleft"></p>
				<p class="alert_btnleft"><a id="succeedmessage_href">{lang message_forward}</a></p>
			</div>
		</div>
	</div>
	<div id="page" class="body_page">
		 <!--{template member/header_simple}-->
        <div id="content" class="cl">
        	<div class="register_module cl" style="background:url({STATICURL}/register_simple/images/Social-Network.jpg) right no-repeat #FFF">
            	<div class="reg_header">
                    <p class="reg_title"><img src="{STATICURL}/register_simple/images/members_48x48.png" align="left" style="padding:10px 5px;" /> <!--{if $_G[gp_action] != 'activation'}-->Đăng ký tài khoản Woo.vn<!--{else}-->{lang index_activation}<!--{/if}--></p>
                    <p class="reg_content">Tham gia woo.vn để luôn luôn sẵn sàng <strong>kết nối với bạn bè</strong>, <strong>đăng tải Hình Ảnh</strong>, <strong>Chia sẻ mọi thứ</strong>, <strong>tạo trang cá nhân theo cách riêng</strong>. Tham gia chợ woo để tự do <strong>Mở cửa hàng online để Bán Hàng</strong> hoặc <strong>Mua Hàng</strong> với cộng đồng Internet. Tất cả đều là miễn phí!</p>
                    <p class="reg_content">Woo.vn - Mạng xã hội đa năng Việt Nam - Vì người dùng phát triển.</p>
                     <!--{hook/register_side_top}-->
                </div>
                <!--{if $this->showregisterform}-->
					<form method="post" name="register" id="registerform" enctype="multipart/form-data" onSubmit="checksubmit(this);return false;" action="member.php?mod=$regname">
                	<input type="hidden" name="regsubmit" value="yes" />
                    <input type="hidden" name="formhash" value="{FORMHASH}" />
                    <input type="hidden" name="referer" value="{echo returnUrl()}" />
                    <input type="hidden" name="activationauth" value="{if $_G[gp_action] == 'activation'}$activationauth{/if}" />
                    <!--{hook/register_top}-->
					<!--{if $invite}-->
						<!--{if $invite['uid']}-->
                        <table class="table_reg" >
                            <tr>
                                <td class="title_tb_reg">{lang register_from}:</td>
                                <td class="input_tb_reg"><a href="home.php?mod=space&uid=$invite[uid]" c="1" target="_blank"><!--{avatar($invite[uid],mid)}--></a></td>
                                <td class="register_chk"></td>
                            </tr>
                        </table>
						<!--{else}-->
                        <table  class="table_reg">
                            <tr>
                                <td class="title_tb_reg"><label for="invitecode">{lang invite_code}:</label></td>
                                <td class="input_tb_reg">$_G[gp_invitecode]<input type="hidden" id="invitecode" name="invitecode" value="$_G[gp_invitecode]" /></td>
                                <td class="register_chk"></td>
                            </tr>
                        </table>
						<!--{eval $invitecode = 1;}-->
						<!--{/if}-->
					<!--{/if}-->
					<!--{if empty($invite) && $this->setting['regstatus'] == 2 && !$invitestatus}-->
                    <table class="table_reg" >
                        <tr>
                            <td class="title_tb_reg"><span class="rq">*</span><label for="invitecode">{lang invite_code}:</label></td>
                            <td class="input_tb_reg"><input type="text" id="invitecode" name="invitecode" autocomplete="off" size="25" onBlur="checkinvite()" tabindex="1" class="px input_reg" required /><!--{if $this->setting['inviteconfig']['buyinvitecode'] && $this->setting['inviteconfig']['invitecodeprice'] && ($this->setting[ec_tenpay_bargainor] || $this->setting[ec_tenpay_opentrans_chnid] || $this->setting[ec_account])}--><p><a href="misc.php?mod=buyinvitecode" target="_blank" class="xi2">{lang register_buyinvitecode}</a></p><!--{/if}--></td>
                            <td class="tipcol"><i id="tip_invitecode" class="p_tip"><!--{if $this->setting['inviteconfig']['invitecodeprompt']}-->$this->setting[inviteconfig][invitecodeprompt]<!--{/if}--></i><kbd id="chk_invitecode" class="p_chk"></kbd></td>
                        </tr>
                    </table>
					<!--{eval $invitecode = 1;}-->
					<!--{/if}-->
                    <table class="table_reg" >
                        <!--{if $_G[gp_action] == 'activation'}-->
                        <tr>
                            <td class="title_tb_reg">{lang username}:</td>
                            <td><strong>$username</strong></td>
                            <td class="register_chk"></td>
                        </tr>
						<!--{/if}-->
                        <!--{if $_G[gp_action] != 'activation'}-->
                        <tr>
                            <td class="title_tb_reg"><label for="{$this->setting['reginput']['username']}">{lang username_select}:</label></td>
                            <td class="input_tb_reg"><input type="text" id="{$this->setting['reginput']['username']}" autocomplete="off" tabindex="1" name="{$this->setting['reginput']['username']}" class="input_reg px" required="required" maxlength="15"/></td>
                            <td class="register_chk"><span id="chk_{$this->setting['reginput']['username']}"></span></td>
                        </tr>
                        <tr>
                            <td class="title_tb_reg"><label for="{$this->setting['reginput']['password']}">{lang password}:</label></td>
                            <td><input type="password" id="{$this->setting['reginput']['password']}" autocomplete="off" tabindex="1" name="{$this->setting['reginput']['password']}" class="input_reg px" required="required"/></td>
                            <td class="register_chk"><span id="chk_{$this->setting['reginput']['password']}"></span></td>
                        </tr>
                        <tr>
                            <td class="title_tb_reg"><label for="{$this->setting['reginput']['password2']}">{lang password_confirm}:</label></td>
                            <td><input type="password" id="{$this->setting['reginput']['password2']}" autocomplete="off" tabindex="1" name="{$this->setting['reginput']['password2']}" class="input_reg px" required="required"/></td>
                            <td class="register_chk"><span id="chk_{$this->setting['reginput']['password2']}"></span></td>
                        </tr>
                        <tr>
                            <td class="title_tb_reg"><label for="{$this->setting['reginput']['email']}">{lang email_address}:</label></td>
                            <td><input type="text" class="input_reg px" required="required" autocomplete="off" tabindex="1" id="{$this->setting['reginput']['email']}" name="{$this->setting['reginput']['email']}" /></td>
                            <td class="register_chk"><span id="chk_{$this->setting['reginput']['email']}"></span></td>
                        </tr>
                        <!--{/if}-->                        
                        <!--{loop $_G['cache']['fields_register'] $field}-->
						<!--{if $htmls[$field['fieldid']]}-->
								<tr>
									<td class="title_tb_reg"><label for="$field['fieldid']">$field[title]:</label></td>
									<td>$htmls[$field['fieldid']]</td>
									<td class="register_chk"><span id="chk_{$field['fieldid']}">&nbsp</span></td>
								</tr>
						<!--{/if}-->
					<!--{/loop}-->

                        <!--{hook/register_input}-->

					<!--{if $secqaacheck || $seccodecheck}-->
						<!--{block sectpl}--><tr><td class="title_tb_reg"><sec>: </td><td colspan="2" class="input_tb_reg"><div class="reg_content"><sec><br /><sec></div></td></tr><!--{/block}-->
						<!--{subtemplate common/seccheck}-->
					<!--{/if}-->
                        <tr>
                            <td class="title_tb_reg"></td>
                            <td colspan="2"><p class="line"><input type="checkbox" class="pc" name="agreebbrule" value="$bbrulehash" id="agreebbrule" checked="checked" />Tôi đồng ý với <a href="javascript:;" onClick="showBBRule()">Điều khoản và Quy định sử dụng</a> mà BQT ban hành.</p></td>
                        </tr>
                        <tr>
                            <td class="title_tb_reg"></td>
                            <td><p class="line"><button type="submit" id="registerformsubmit" name="regsubmitbtn" class="button_sb">Đăng Ký</button></td>
                            <td><!--{if $this->setting['sitemessage'][register]}--><a href="javascript:;" id="custominfo_register" class="y"><img src="{IMGDIR}/info_small.gif" alt="{lang faq}" /></a><!--{/if}--></td>
                        </tr>
                    </table>
                </form>
                <p id="returnmessage4"></p>
                <!--{/if}-->
				<!--{hook/register_bottom}-->
            </div>
            <div class="member_box"></div>
        </div>
    </div>
<div id="layer_bbrule" style="display: none">
    <div class="c" style="width:700px;height:350px;overflow:auto">$bbrulestxt</div>
    <p class="fsb pns cl hm">
        <button class="pn pnc" onClick="$('agreebbrule').checked = true;hideMenu('fwin_dialog', 'dialog');{if $this->setting['sitemessage'][register] && ($bbrules && $bbrulesforce)}showRegprompt();{/if}"><span>{lang agree}</span></button>
        <button class="pn" onClick="location.href='$_G[siteurl]'"><span>{lang disagree}</span></button>
    </p>
</div>
<script type="text/javascript">
<!--{if $bbrules && $bbrulesforce}-->
	showBBRule();
<!--{/if}-->
<!--{if $this->showregisterform}-->
	<!--{if $this->setting['sitemessage'][register]}-->
		function showRegprompt() {
			showPrompt('custominfo_register', 'mouseover', '<!--{echo trim($this->setting['sitemessage'][register][array_rand($this->setting['sitemessage'][register])])}-->', $this->setting['sitemessage'][time]);
		}
		<!--{if !($bbrules && $bbrulesforce)}-->
			showRegprompt();
		<!--{/if}-->
	<!--{/if}-->
	function showBBRule() {
		showDialog($('layer_bbrule').innerHTML, 'info', '{echo addslashes($this->setting['bbname']);} {lang rulemessage}');
		$('fwin_dialog_close').style.display = 'none';
	}
<!--{/if}-->
</script>
 <!--{template common/footer}-->

